package com.ziroom.zifamily.zfms.logic.conser;

import com.ziroom.zifamily.base.utils.collections.ZfUtilList;
import com.ziroom.zifamily.bussiness.common.pojo.dto.ManualCensorDTO;
import com.ziroom.zifamily.bussiness.common.result.Result;
import com.ziroom.zifamily.zfms.common.util.UserUtils;
import com.ziroom.zifamily.zfms.pojo.dto.CensorReqDTO;
import com.ziroom.zifamily.zfms.service.conser.CensorContentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.util.List;
/**
 * <p></p>
 * <p>
 * <PRE>
 * <BR>    修改记录
 * <BR>-----------------------------------------------
 * <BR>    修改日期         修改人          修改内容
 * </PRE>
 *
 * @author xgh
 * @version 1.0
 * @date Created in 2018年12月3日 14:02
 * @since 1.0
 */
@Component
@Slf4j

public class ConserContentLogic {

    @Autowired
    private CensorContentService censorContentService;
    @Autowired
    private RestTemplate restTemplate;

    public ResponseEntity<Result> sendRequestToCensorService(String censorServiceUrl, CensorReqDTO request){
        ManualCensorDTO manualCensorDTO = new ManualCensorDTO();
        List<String> censorIdList = request.getList();
        String censorIdString = ZfUtilList.listToString(censorIdList,',');
        manualCensorDTO.setCensorIds(censorIdString);
        manualCensorDTO.setCensorLevel(request.getCensorLevel());
        manualCensorDTO.setCensorCode(UserUtils.getUserInfo().getSystemCode());
        ResponseEntity<Result> responseEntity = restTemplate.postForEntity(censorServiceUrl,manualCensorDTO,Result.class);
        return responseEntity;
    }
}
